package com.android.tnovoselec.schedule.db;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.android.tnovoselec.schedule.dto.ItemDto;
import com.j256.ormlite.dao.Dao;
import com.tnovoselec.android.favorites.db.FavoritesDatabaseHelper;

public class ScheduleDatabaseHelper extends FavoritesDatabaseHelper {

	private static String DATABASE_NAME = "schedule.db";
	private static int DATABASE_VERSION = 1;

	private Dao<ItemDto, String> scheduleDao = null;
	private Context mContext;

	public ScheduleDatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		this.mContext = context;
	}

	@Override
	public String getDatabaseName() {
		return DATABASE_NAME;
	}

	@Override
	public int getDatabaseVersion() {
		return DATABASE_VERSION;
	}

	@Override
	public List<String> getCreateQueries() {
		List<String> queries = new ArrayList<String>();
		queries.add(ItemDto.getCreateQuery());
		return queries;
	}

	@Override
	public List<Class> getDtoClasses() {

		List<Class> classes = new ArrayList<Class>();
		classes.add(ItemDto.class);
		return classes;
	}

	public Dao<ItemDto, String> getScheduleDao() throws SQLException {
		if (scheduleDao == null) {
			scheduleDao = super.getDao(ItemDto.class);
		}

		return scheduleDao;
	}

}
